home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 1 / Mac Magazin and MacEasy Magazine CD - Issue 01.iso / Sharewarebibliothek / Powermac / C64 / SOURCE / Printer.c < prev    next >
Text File  |  1994-06-06  |  2KB  |  83 lines

  1. /*
  2.     Commodore 64 Emulator v0.4      Earle F. Philhower III 
  3.     Copyright (C) 1993-4            (st916w9r@dunx1.ocs.drexel.edu)
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #include "Processor.h"
  21. #include "Serial.h"
  22. #include "Printer.h"
  23. #include "FileTypes.h"
  24. #include "Error.h"
  25.  
  26. static short printerFile;
  27. static byte printerOpen;
  28.  
  29. static byte PrinterClose(int sa);
  30. static byte PrinterOpen(char *fname, int len, int sa);
  31. static byte PrinterOutput(byte chr, int sa);
  32. static byte PrinterInput(byte *store, int sa);
  33.  
  34. int PrinterInitialize(void)
  35. {
  36.     AddSerialDevice(4, PrinterInput, PrinterOutput, PrinterOpen,
  37.         PrinterClose, NULL);
  38.     printerOpen=0;
  39.     
  40.     return kNoError;
  41. }
  42.  
  43. static byte PrinterClose(int sa)
  44. {
  45.     if (printerOpen==1) FSClose(printerFile);
  46.     printerOpen=0;
  47.     return kSerialOK;
  48. }
  49.  
  50. static byte PrinterOpen(char *fname, int len, int sa)
  51. {
  52.     if (printerOpen==1) PrinterClose(sa);
  53.     
  54.     FSDelete("\pPRINTER",0);
  55.     Create("\pPRINTER",0, APPLTYPE, PRINTERFTYPE);
  56.     FSOpen("\pPRINTER",0, &printerFile);
  57.     printerOpen=1;
  58.     return kSerialOK;
  59. }
  60.  
  61. static byte PrinterOutput(byte chr, int sa)
  62. {
  63.     long len;
  64.     char temp;
  65.  
  66.     if (printerOpen==1) {
  67.         temp=chr;
  68.         len=1;
  69.         FSWrite(printerFile, &len, &temp);
  70.         return kSerialOK; }
  71.     return kSerialError;
  72. }
  73.  
  74. static byte PrinterInput(byte *store, int sa)
  75. {
  76.     return kSerialError;
  77. }
  78.  
  79. void PrinterNewFile(void) {}
  80. void PrinterAppendFile(void) {}
  81. void PrinterXvertCharacters(void) {}
  82. void PrinterDisplayFile(void) {}
  83.